function equal_size_using_jpeg(input_folder,output_folder,comprassion_folder)

% in this program I equlilzes the size of already doubly compressed images
% with already single compressed images with quality 75. 

%we first
clc;
close all;


% Iput folder

a=input_folder;
c=output_folder;

% out put folder
%c=folder_for_Double_comp;

d=dir([a '*.jpg']);

%path of the folder to caompre the sizes, This path is to already doubly compressed
%images

c3030=comprassion_folder;

%mkdir(c);


for i=[1:numel(d)]
    org=imread([a d(i).name]); 
   
   img_new_name= strrep([c d(i).name],'.tif','.jpg');
   
   
  
    imwrite(org,img_new_name, 'jpg' , 'quality' , 100);
    K=imfinfo(img_new_name , 'jpg');
  
    
     K1=imfinfo([c3030 d(i).name], 'jpg');
     image_byte = K1.FileSize;
     compressed_byte=K.FileSize;
     CR =  image_byte /compressed_byte;
    if CR > 50
        for m=[1:1:49]

            if CR > 1            

                imwrite(org,img_new_name , 'jpg','quality', 50+m);

                K=imfinfo(img_new_name, 'jpg');         
                compressed_byte=K.FileSize;

                CR =  image_byte /compressed_byte;


            end
        end 
    end 

   %delete([ d(i).name],'jp2');
   
    if CR < 50
        for m=[1:1:49]

            if CR < 1            

                imwrite(org,img_new_name , 'jpg','quality', 50-m);

                K=imfinfo(img_new_name, 'jpg');         
                compressed_byte=K.FileSize;

                CR =  image_byte /compressed_byte;


            end
        end 
    end 
end

    
    

